home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / lib / init / splash-functions < prev    next >
Encoding:
Text File  |  2009-02-07  |  1.8 KB  |  109 lines

  1. # Usplash hooks for /lib/init/splash-functions-base
  2.  
  3. # Internal function, do not use in external scripts
  4. usplash_pidfound()
  5. {
  6.     pidof usplash > /dev/null 2>&1 || return 1
  7.     return 0
  8. }
  9.  
  10. splash_running()
  11. {
  12.     if [ -x /sbin/usplash ] && usplash_pidfound; then
  13.         return 0
  14.     fi
  15.     return 1
  16. }
  17.  
  18. splash_stop()
  19. {
  20.     local i
  21.  
  22.     splash_running || return 0
  23.  
  24.     export SPLASH_ORIG_CONSOLE="$(fgconsole)"
  25.  
  26.     # Clear VT 8 of any console messages
  27.     clear >/dev/tty8
  28.  
  29.     # Ask usplash to go away
  30.     /sbin/usplash_write QUIT
  31.  
  32.     # Wait until it is gone or forcibly kill it
  33.     i=0
  34.     while usplash_pidfound; do
  35.         i=$(($i + 1))
  36.         if [ $i -gt 100 ]; then
  37.             kill -9 $(pidof usplash)
  38.             break
  39.         fi
  40.         sleep 0.1
  41.     done
  42.  
  43.     # Reset virtual consoles if necessary
  44.     if ! type setupcon >/dev/null 2>&1 && \
  45.        [ -x /etc/init.d/console-screen.sh ]; then
  46.         /etc/init.d/console-screen.sh start
  47.     fi
  48.  
  49.     return 0
  50. }
  51.  
  52. splash_start()
  53. {
  54.     if splash_running; then
  55.         return 0
  56.     elif [ ! -x /sbin/usplash ] || [ ! -x /sbin/usplash_down ]; then
  57.         return 1
  58.     fi
  59.  
  60.     /sbin/usplash_down || return 1
  61.     return 0
  62. }
  63.  
  64. custom_splash_progress()
  65. {
  66.     splash_running || return 0
  67.     /sbin/usplash_write "PROGRESS $1" || return 1
  68.     return 0
  69. }
  70.  
  71. splash_start_indefinite()
  72. {
  73.     splash_running || return 0
  74.     # TIMOUT 0 is not indefinite
  75.     /sbin/usplash_write "TIMEOUT 600" || return 1
  76.     /sbin/usplash_write "PULSATE" || return 1
  77.     return 0
  78. }
  79.  
  80. splash_stop_indefinite()
  81. {
  82.     splash_running || return 0
  83.     /sbin/usplash_write "TIMEOUT 15" || return 1
  84.     return 0
  85. }
  86.  
  87. splash_user_input()
  88. {
  89.     splash_running || return 1
  90.     [ -p /dev/.initramfs/usplash_outfifo ] || return 1
  91.  
  92.     case "$2" in
  93.         regular)
  94.         /sbin/usplash_write "INPUT $1" || return 1
  95.         ;;
  96.         password)
  97.         /sbin/usplash_write "INPUTQUIET $1" || return 1
  98.         ;;
  99.         enter)
  100.         /sbin/usplash_write "INPUTENTER $1" || return 1
  101.         ;;
  102.         *)
  103.         return 1
  104.         ;;
  105.     esac
  106.     cat /dev/.initramfs/usplash_outfifo 2> /dev/null || return 1
  107.     return 0
  108. }
  109.